import java.sql.Time;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: rei
 * Date: 2025-11-17
 * Time: 19:53
 */
public class Test2 {
    public static void main(String[] args) throws InterruptedException {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(3,
                7,3, TimeUnit.SECONDS,new LinkedBlockingQueue<>(5),
                new ThreadPoolExecutor.DiscardPolicy() );


        for (int i = 0; i < 100; i++) {
            int taskId = i + 1;
            threadPoolExecutor.submit(() ->{
                System.out.println(Thread.currentThread().getName() + "执行" + taskId);
            });

            /*if (taskId % 2 == 0){
                TimeUnit.SECONDS.sleep(2);
            }*/

        }
    }
}
